package com.yigang.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.druid.filter.AutoLoad;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yigang.dao.UserAddressDao;

import com.yigang.entity.UserAddress;
import com.yigang.service.UserAddressService;
import com.yigang.utils.ResultUtil;
@Service
@Transactional
public class UserAddressServiceImpl implements UserAddressService{
	
	@Autowired
	UserAddressDao userAddressDao;
	@Override
	public List<UserAddress> getAllUserAddress(UserAddress userAddress) {
		// TODO Auto-generated method stub
		return userAddressDao.getAllUserAddress(userAddress);
	}
	@Override
	public List<UserAddress> getAllUserAddress1(UserAddress userAddress) {
		// TODO Auto-generated method stub
		return userAddressDao.getAllUserAddress1(userAddress);
	}
	@Override
	public ResultUtil selectUserAddressList(Integer page, Integer limit, UserAddress record) {
		// TODO Auto-generated method stub
		PageHelper.startPage(page, limit);
		List<UserAddress> activity = userAddressDao.selectUserAddressList(record);
		PageInfo<UserAddress> pageInfo = new PageInfo<UserAddress>(activity);
		ResultUtil resultUtil = new ResultUtil();
		resultUtil.setCode(0);
		resultUtil.setCount(pageInfo.getTotal());
		resultUtil.setData(pageInfo.getList());
		return resultUtil;
	}
	@Override
	public int deleteByPrimaryKey(UserAddress userAddress) {
		// TODO Auto-generated method stub
		
		return userAddressDao.deleteByPrimaryKey(Integer.valueOf(userAddress.getAddress_id()));
	}
	@Override
	public ResultUtil insertSelective(UserAddress record) {
		// TODO Auto-generated method stub
		userAddressDao.insertSelective(record);
		return ResultUtil.ok();
	}
	@Override
	public ResultUtil updateByPrimaryKeySelective(UserAddress record) {
		// TODO Auto-generated method stub
		userAddressDao.updateByPrimaryKeySelective(record);
		return ResultUtil.ok();
	}
	@Override
	public UserAddress selectUserAddressById(int address_id) {
		// TODO Auto-generated method stub
		return userAddressDao.selectUserAddressById(address_id);
	}

}
